home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / ada / gnat1792.zip / gnat179b / examples / instr.ads < prev    next >
Text File  |  1994-05-13  |  2KB  |  81 lines

  1. package Instr is 
  2.  
  3.    --   Instruments for a Dashboard
  4.    --
  5.    --   Instrument ---- Speedometer
  6.    --              |
  7.    --              ---- Gauge ---- Graphic_Gauge
  8.    --              |
  9.    --              ---- Clock ---- Chronometer
  10.  
  11.  
  12.    -----------------
  13.    --  Root Type  --
  14.    -----------------
  15.  
  16.    type Instrument is tagged record
  17.       Name : String (1 .. 14) := "            ";
  18.    end record;
  19.    
  20.    procedure Set_Name (I : in out Instrument; S : String);
  21.    procedure Display_Value (I : Instrument);
  22.  
  23.    -------------------
  24.    --  Speedometer  --
  25.    -------------------
  26.  
  27.    subtype Speed is Integer range 0 .. 85; -- mph
  28.    
  29.    type Speedometer is new Instrument with record 
  30.       Value : Speed;
  31.    end record;
  32.  
  33.    procedure Display_Value (S : Speedometer);
  34.       
  35.    -----------------
  36.    --   Gauges    --
  37.    -----------------
  38.  
  39.    subtype Percent is Integer range 0 .. 100;
  40.    
  41.    type Gauge is new Instrument with record
  42.       Value : Percent;
  43.    end record;
  44.  
  45.    procedure Display_Value (G : Gauge);
  46.    
  47.    type Graphic_Gauge is new Gauge with record
  48.       Size  : Integer := 20;
  49.       Fill  : Character := '*';
  50.       Empty : Character := '.';
  51.    end record;
  52.  
  53.    procedure Display_Value (G : Graphic_Gauge);
  54.    
  55.    -----------------
  56.    --   Clocks    --
  57.    -----------------
  58.  
  59.    subtype Sixty is Integer range 0 .. 60;
  60.    subtype Twenty_Four is Integer range 0 .. 24;
  61.    
  62.    type Clock is new Instrument with record 
  63.       Seconds : Sixty := 0;
  64.       Minutes : Sixty := 0;
  65.       Hours : Twenty_Four := 0;
  66.    end record;
  67.  
  68.    procedure Display_Value (C : Clock);   
  69.    procedure Init (C : in out Clock; 
  70.                    H : Twenty_Four := 0; 
  71.                    M, S : Sixty := 0);
  72.  
  73.    procedure Increment (C : in out Clock; Inc : Integer :=1); 
  74.  
  75.    type Chronometer is new Clock with null record;
  76.  
  77.    procedure Display_Value (C : Chronometer);
  78.    
  79. end Instr;
  80.  
  81.